﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Printing;
using System.Drawing;

namespace Negocio
{
    public static class ControladorImpresion
    {
       public static List<string> listaAImprimir = new List<string>();
        public static void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            
            Font printFont = new Font("Arial", 12);
            float yPos = 0;
            float xPos = 0;
            int count = 0;
            float leftMargin = ev.MarginBounds.Left;
            float topMargin = ev.MarginBounds.Top;
            for (int i = 0; i < listaAImprimir.Count; i++)
            {
                string s = listaAImprimir[i];
                yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));
                xPos = leftMargin;
                PointF point = new PointF();
                point.Y = yPos;
                point.X = xPos;
                ev.Graphics.DrawString(s, printFont, System.Drawing.Brushes.Black, point, new StringFormat());
                count++;
            }
        }
        public static void Imprimir()
        {
            PrintDocument pd = new PrintDocument();
            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
            pd.Print();
        }
    }
}
